<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Insert title here</title>
        <script src="/lib/axios.js"></script>
        <script src="/lib/vue.js"></script>
        <link rel="stylesheet" href="/lib/elementindex.css">
        <script src="/lib/elementindex.js"></script>
    </head>
    <body>
        <div id="app">
            <el-upload action="https://none" :file-list="fileList" :multiple='false' :auto-upload="false" :on-change="handleUploadChange">
                <el-button slot="trigger" size="small" type="primary">选取配置文件</el-button>
                <el-button style="margin-left: 10px;" size="small" type="success" @click="handleConfigUpload">上传到服务器</el-button>
                <div slot="tip" class="el-upload__tip">只能上传config文件，且不超过3Mb</div>
            </el-upload>
        </div>
        <script type='module'>
            import * as $util from '/lib/hc-util.js'
           import * as $rest from '/lib/hc-rest-service.js'
           import {} from '/com/hc-test.js'
           
           $rest.obtainRuleDefByRpath($util.getUrlArgOrDefault('rpath', 'xsxdjc/Main'), function(ruleDef) {
           window.vm = new Vue({
                   el: '#app',
                   data: {
                      fileList:[]
                   },
                   methods: {
                      handleChange(file, fileList) {
                              this.fileList = fileList.slice(-1);
                            }
                   }
               });
           });
       </script>
        <input type="file" id="file" onchange="handleFiles(this.files)" />
        <input type="file" id="file2" onchange="abc(this)" accept="image/png, image/jpeg" />
        <div id="filecontent"></div>
        <script>
            function handleFiles(files1) {
                console.warn(files1);
                console.warn(this.files);
                let files = this.files;
                if (files.length) {
                    var file = files[0];
                    var reader = new FileReader();
                    reader.onload = function() {
                        console.log(this.result)
                        document.getElementById("filecontent").innerHTML = this.result;
                    };
                    reader.readAsText(file);
                }
            }

            function abc(self) {
                console.log(self.files)
                let f = document.getElementById("file2").files
                console.log(f)
            }
            // let input = document.getElementById('file')
            // input.addEventListener('change',handleFiles,false);
        </script>
    </body>
</html>
